package laravel.mvc.view;

import html.A;
import html.Li;
import html.Nav;
import html.Ul;
import utils.VirtualFolder;
import utils.files.File;

/**
 * Created by thormentor on 29-04-2014.
 */
public class LeftMenu extends File {
    private final Ul innerUl = new Ul();

    private static final VirtualFolder FOLDER = View.FOLDER.create("layout");

    public LeftMenu() {
        super(FOLDER, "left_menu", "blade.php");

        Nav nav = new Nav();
        add(nav);

        Ul ul = (Ul) new Ul().addClass("nav navbar-nav side-nav");
        nav.appendChild(ul);
        ul.appendChild(createLi("Home", "home"));

        Li li = new Li();
        ul.appendChild(li);
        li.appendChild(innerUl);

        ul.appendChild(createLi("Sign in", "account-sign-in"));
        ul.appendChild(createLi("Create an account", "account-create"));
    }

    public void createLink(String text, String route) {
        innerUl.appendChild(createLi(text, route));
    }

    private Li createLi(String text, String route) {
        Li li = new Li();

        li.appendChild(new A(text, "{{ URL::route('" + route + "') }}"));

        return li;
    }
}
